﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using KZ.Utilities;
using KZ.Express.H.ENT;
using KZ.Express.H.Presenter;
using KZ.Express.H.BLL;

namespace KZ.Express.H.Settings.Carriers
{
    public partial class CarrierDetailView : BaseView
    {
        #region Private Variables


        #endregion Private Variables

        #region Private Methods

        private void CarrierDetailView_Load(object sender, EventArgs e)
        {
            LoadData();
        }

     

        private void LoadData()
        {
            try
            {
                switch (this.ActionName)
                {
                    case "Insert":
                        break;

                    case "Update":
                        _presenter.LoadEntity<CarrierENT>();
                        break;
                }
            }
            catch (BusinessLogicException ex)
            {
                ShowMessageBoxError(ex.Message);
            }
        }


        #endregion Private Methods

        #region Constructors

        public CarrierDetailView()
        {
            InitializeComponent();

            _presenter = new BasePresenter(this);
            this.ObjectID = (int)Objects.Carrier;
        }

        #endregion Constructors

        #region Public Properties

        [Search]
        public int CarrierID
        {
            get { return base.EntityID; }
        }

        public override BaseENT Entity
        {
            get
            {
                CarrierENT supplier = new CarrierENT();
                supplier.CarrierID = base.EntityID;
                supplier.CarrierName = txtCarrierName.Text;


                supplier.CreatedBy = UserENT._USERID;
                supplier.UpdatedBy = UserENT._USERID;
                supplier.ValidateData();

                return supplier;
            }
            set
            {
                CarrierENT user = value == null ? new CarrierENT() : value as CarrierENT;
                txtCarrierName.Text = user.CarrierName;
             
            }
        }

        #endregion Public Properties

        #region Public Methods

        public override void Save()
        {
            try
            {
                _presenter.Save();
            }
            catch (BusinessLogicException ex)
            {
                ShowMessageBoxError(ex.Message);
            }
        }

        #endregion Public Methods
    }
}
